/**
 * Toast提示框
 * @param {*} message  提示的文本内容
 * @param {*} time  提示框出现的时长,默认2秒后自动关闭
 */
export default function (message, type = 1, time = 2000) {
    /*设置信息框停留的默认时间*/
    var el = document.createElement("div");
    if (type == 1) {
        el.setAttribute("class", "web-toast web-toast-normal");
    } else if (type == 2) {
        el.setAttribute("class", "web-toast web-toast-warn");
    }

    el.innerHTML = message;
    document.body.appendChild(el);
    el.classList.add("toast-fade-in");
    setTimeout(function () {
        el.classList.remove("toast-fade-in");
        el.classList.add("toast-fade-out");
        /*监听动画结束，移除提示信息元素*/
        el.addEventListener("animationend", function () {
            document.body.removeChild(el);
        });
        el.addEventListener("webkitAnimationEnd", function () {
            document.body.removeChild(el);
        });

    }, time);
}